package com.ruoyi.develop.goodsInvoiceInfo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.goodsInvoiceInfo.domain.GoodsInvoiceInfo;
import com.ruoyi.develop.goodsInvoiceInfo.service.IGoodsInvoiceInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 开票明细信息Controller
 * @author qh
 * @date 2023-12-05
 */
@RestController
@RequestMapping("/goodsInvoiceInfo/goodsInvoiceInfo")
public class GoodsInvoiceInfoController extends BaseController {
    @Autowired
    private IGoodsInvoiceInfoService goodsInvoiceInfoService;

    /**
     * 查询开票明细信息列表
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsInvoiceInfo:query')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsInvoiceInfo entity) {
        startPage();
        List<GoodsInvoiceInfo> list = goodsInvoiceInfoService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出开票明细信息列表
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsInvoiceInfo:export')")
    @Log(title = "开票明细信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsInvoiceInfo entity) {
        List<GoodsInvoiceInfo> list = goodsInvoiceInfoService.selectList(entity);
        ExcelUtil<GoodsInvoiceInfo> util = new ExcelUtil<GoodsInvoiceInfo>(GoodsInvoiceInfo. class);
        util.exportExcel(response, list, "开票明细信息数据");
    }

    /**
     * 获取开票明细信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsInvoiceInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(goodsInvoiceInfoService.selectById(id));
    }

    /**
     * 新增开票明细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsInvoiceInfo:add')")
    @Log(title = "开票明细信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody GoodsInvoiceInfo entity) {
        return goodsInvoiceInfoService.insert(entity);
    }

    /**
     * 修改开票明细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsInvoiceInfo:edit')")
    @Log(title = "开票明细信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody GoodsInvoiceInfo entity) {
        return toAjax(goodsInvoiceInfoService.update(entity));
    }

    /**
     * 删除开票明细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsInvoiceInfo:remove')")
    @Log(title = "开票明细信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(goodsInvoiceInfoService.deleteByIds(ids));
    }
}
